package com.scedu.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.scedu.enums.ProductStatusEnums;
import com.scedu.utils.EnumUtil;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;


import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;

@Entity //实体类
@Table(name = "product_info")
@DynamicUpdate
@DynamicInsert
@Data //等于getter setter

public class ProductInfo {
    @Id
    private  String productId;
    private String productName;
    private BigDecimal productPrice;
    private  Integer productStock;
    private String productDescription;
    private String productIcon;
    private Integer productStatus=ProductStatusEnums.ONLINE.getCode();
    private Integer categoryType;
    private Date create_time;
    private  Date  update_time;

    public ProductInfo() {
    }

    public ProductInfo(String productId, String productName, BigDecimal productPrice, Integer productStock, String productDescription, String productIcon, Integer productStatus, Integer categoryType) {
        this.productId = productId;
        this.productName = productName;
        this.productPrice = productPrice;
        this.productStock = productStock;
        this.productDescription = productDescription;
        this.productIcon = productIcon;
        this.productStatus = productStatus;
        this.categoryType = categoryType;
    }
    @JsonIgnore //会多出getOrderStatusEnums属性
    public ProductStatusEnums geProductStatusEnums(){
        return EnumUtil.getByCode(productStatus,ProductStatusEnums.class);

    }
}
